

using System.Collections.Generic;
using System.Data.Objects.DataClasses;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace UserBook.Repository
{
	[ExcludeFromCodeCoverage]
    public partial class MemoryRepository<E> : IRepository<E> where E : EntityObject
    {
        public MemoryRepository()
        {
        }

        public MemoryRepository(IEnumerable<E> entities)
        {
            if (entities != null)
            {
                foreach (var entity in entities)
                {
                    Add(entity);
                }
            }
        }

        public MemoryRepository(params E[] entities)
        {
            if (entities != null)
            {
                foreach (var entity in entities)
                {
                    Add(entity);
                }
            }
        }

        protected readonly List<E> objectSet = new List<E>();

        public virtual IQueryable<E> All()
        {
            return objectSet.AsQueryable();
        }

        public virtual IQueryable<E> All(string includes)
        {
            return All();
        }

        public virtual void Add(E entity)
        {
            objectSet.Add(entity);
        }

        public virtual void Remove(E entity)
        {
            objectSet.Remove(entity);
        }

        public virtual void Update(E entity)
        {
        }

        public virtual void Save()
        {
        }
	}
}

